package logic;

import gamepieces.Armory;
import gamepieces.Cannon;
import gamepieces.Catapult;
import gamepieces.House;
import gamepieces.Interior;

import java.util.Vector;

import visual.GameDef;

public class Manager implements GameDef{
/*
 * Atributes
 */
	private Vector <Player>players;
	private int numPlayers;
	private int currentPlayer;
	private int lastPlayer;
	final static int MAX_PLAYERS = 6;
	
/*
 * Constructor
 */
	public Manager(){
		numPlayers = MAX_PLAYERS;
		newGame();
	}

	public Manager(int _numPlayers){
		numPlayers = _numPlayers;
		newGame();
	}
	
/*
 * Setters
 */
	
/*
 * Getters
 */

/*
 * Methods
 */
	public void newGame(){
		players = new Vector<Player>(0);
	}
	
	public void addPlayer(String playerName){
		int cantPlayers = players.size();
		players.add(new Player(playerName, cantPlayers));
	}
	
	public void startGame(){
	
	}
	
	public int getPieceType(String piece){
		for(int i = 0; i < STRING_PIECES.length; i++){
			if(piece.equals(STRING_PIECES[i]))
				return i;
		}
		
		return -1;
	}
	
	public void addPiece(String piece){
		Player p = (Player)players.get(currentPlayer);

		switch(getPieceType(piece)){
			case ID_INTERIOR:
				p.getCastle().add(new Interior());
				break;
			case ID_HOUSE:
				p.getCastle().add(new House());
				break;
			case ID_CATAPULT:
				p.getCastle().add(new Catapult());
				break;
			case ID_CANNON:
				p.getCastle().add(new Cannon());
				break;
			case ID_ARMORY:
				p.getCastle().add(new Armory());
				break;
		}
	}
}
